<!DOCTYPE HTML>
<!-- 汽车贷款计算器-->
<html>
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="maximum-scale=1.0, minimum-scale=1.0, user-scalable=0, initial-scale=1.0, width=device-width" />
        <meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
        <!-- <title>Hello APP</title> -->
        <link rel="stylesheet" type="text/css" href="../css/api.css" />
        <style>
            * {
              margin: 0;
              padding: 0;
            }
            body {
              margin: 10px;
              padding: 10px;
            }
           .p1 {
                margin: 20px 0px 10px 0px;
                font-size: 30
            }

            .p2 {
                margin: 10px 10px 10px 0px;
                font-size: 20
            }
            .loanAmount {
                border: 0.5px solid #378888;
                height: 30px;
                width: 100px;
                margin: 10px 0px 10px 0px;
                padding: 0;
                line-height：100%;
            }
            .jiSuan {
                margin: 10px 0px 10px 0px;
                height: 40px;
                width: 300px;
                background: #FFBAB3 100%;
                border: 1px solid #eee;
            }
            .XXX{
              height: 45px;
            }
            hr{
                border-bottom: 2px solid;
            }
        </style>
    </head>

    <body>
        <!-- <label>Hello APP</label> -->
        <div id='sys-info'></div>
    </body>
    <script type="text/javascript" src="../lib/api.js"></script>
    <script type="text/javascript">
      function jiSuan(){
        var   loanAmount = $api.byId("loanAmount").value.trim();
        var   interestRate = $api.byId("interestRate").value.trim();
        var   fq = 36;
        if(interestRate>=326 ){
          //实际贷款额：ROUNDUP(B3*C3*D3/1.09/10000/10000,1)*10000
          var sjdke=Math.ceil(loanAmount*interestRate*fq/1.09/10000/10000*10)*1000;
          // 还款总额 =E3*1.09
          var hkze=Math.ceil(sjdke*1.09);
          // 月供  E3*1.09/36
          var yg=Math.ceil(hkze/fq);
          // 返利 =(C3-326)*36*0.9/10000*B3
          var fl=Math.ceil((interestRate-326)*fq*0.9/10000*loanAmount);
          $api.html($api.byId("sjdke"), sjdke+"元");
          $api.html($api.byId("sjdke"), sjdke+"元");
          $api.html($api.byId("hkze"), hkze+"元");
          $api.html($api.byId("yg"), yg+"元");
          $api.html($api.byId("fl"), fl+"元");      }
        else {
            $api.toast( '年利率不能低于326',5000);    }
      }
    </script>
    <div>
      <p class="p1">亲 等你很久了</p>
      <p class="p2">今年春节可以开车回家 激动吧</p>
      <hr />
      <div class="XXX">
          <label class="p2">请输入贷款额:</label>
          <input class="loanAmount" id="loanAmount" type="number"   value="80000"></input>
      </div>
      <div class="XXX">
        <label class="p2">请选择年利率:</label>
        <input class="loanAmount" id="interestRate" type="number"  min="326" max="400" value="334" />‱
      </div>
      <p  class="p2">贷款期限：36个月<br></p>
      <button class="jiSuan" id="jiSuan" onclick="jiSuan()">计算</button>
      <hr />
      <p class="p2">实际贷款额：<label class="p2" id="sjdke" >元<br>
      <p class="p2">还款总额：<label class="p2" id="hkze">元<br>
      <p class="p2">月供：<label class="p2" id="yg">元<br>
      <p class="p2">返利：<label class="p2" id="fl">元<br>
    </div>
</html>
